package com.java01;

import java.util.Scanner;

public class eleventhjava {
    public static void main(String[] args) {
        /*
        定义数组
         */
        double sum = 0;
        double[] hens = {3,5,1,3.4,2,50};
        for (int i = 0;i < hens.length;i++){
            sum += hens[i];
        }
        System.out.println(sum/hens.length);
    }
}

class work02{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a[]= new int[5];
        for (int i = 0;i < a.length;i++){
            System.out.println("请输入第"+ (i+1) +"个数:");
            a[i] = scanner.nextInt();
        }
        for (int i =0;i<a.length;i++){
            System.out.print(a[i]);
            System.out.print(",");
        }
    }
}

class arrayexercise01{
    public static void main(String[] args) {
        char a[] = new char[26];
        for (int i = 0;i < a.length;i++){
            a[i] =(char)('A'+ i);
        }
        for (int i = 0;i < a.length;i++){
            System.out.print(a[i]+" ");
        }
    }
}
class arrayexercise02{
    public static void main(String[] args) {
        int i = 1,a[] = {4,-1,9,10,23},max = a[0],maxindex = 0;
        for (;i<a.length;i++){
            if (max < a[i]){
                max = a[i];
                maxindex = i;
            }
        }
        System.out.println("数组最大值是"+ max +",下标为"+maxindex);
    }
}
class work03{
    public static void main(String[] args) {
//        int n1 = 3;
//        int n2 = n1;
//        n1 = 10;
//        System.out.println(n1+","+n2);
        int arr[] = {1,2,3};
        int arr1[] = arr;
        arr1[0]= 3;
        for (int i = 0;i<arr.length;i++){
            System.out.println(arr[i]);
            System.out.println();
            System.out.println(arr1[i]);
        }
    }
}

class array01{
    public static void main(String[] args) {
        int temp = 0;
        int arr01[] = {11,22,33,44,55,66};
        for (int i = 0;i < arr01.length / 2;i++){
            temp = arr01[i];
            arr01[i] = arr01[arr01.length-1-i];
            arr01[arr01.length-1-i] = temp;
        }
        for (int i = 0;i < arr01.length;i++){
            System.out.print(arr01[i]+" ");
        }
    }
}

class array02{
    public static void main(String[] args) {
        int arr01[] = {11,22,33,44,55,66};
        int arr02[] = new int[arr01.length];
        for ( int i = arr01.length-1; i>=0;i--){
            arr02[arr01.length-1-i] = arr01[i];
        }
        arr01 = arr02;
        for (int i = 0;i < arr01.length;i++){
            System.out.print(arr01[i]+",");
        }
    }
}

class arrayadd01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int arr01[] = {1, 2, 3};
        while (true) {
            int arr02[] = new int[arr01.length + 1];
            for (int i = 0; i < arr01.length; i++) {
                arr02[i] = arr01[i];
            }
            System.out.println("请输入要添加的数字：");
            arr02[arr01.length] = scanner.nextInt();
            arr01 = arr02;
            for (int i = 0; i < arr01.length; i++) {
                System.out.print(arr01[i] + " ");
            }
            System.out.println();
            System.out.println("是否继续添加 y/n：");
            char c = scanner.next().charAt(0);
            if (c == 'n' || c == 'N'){
                break;
            }
        }
    }

}
class arraydec01{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int arr01[] = {1,2,3,4,5,6,7,8,9};
        while (true) {
            int arr02[] = new int[arr01.length - 1];
            for (int i = 0; i < arr02.length; i++) {
                arr02[i] = arr01[i];
            }
            arr01 = arr02;
            for (int i = 0; i < arr01.length; i++) {
                System.out.print(arr01[i] + ",");
            }
            System.out.println();
            System.out.println("是否继续删除最后一个数组元素 y/n:");
            char c = scanner.next().charAt(0);
            if (arr01.length == 1){
                System.out.println("数组只剩下最后一个元素，无法删除！");
                break;
            }else if (c == 'n' || c == 'N'){
                break;
            }
        }
    }
}